Page({


    onReady(){

        wx.login({
            timeout:10000,
            success: (result)=>{
                console.log(result);
                if(result.code){
                        var reqTask = wx.request({
                            url: 'https://test.com/onLogin',
                            data: {
                            code: result.code
                            },
                            header: {'content-type':'application/json'},
                            method: 'GET',
                            dataType: 'json',
                            responseType: 'text',
                            success: (result)=>{
                                console.log(result);
                            },
                            fail: ()=>{},
                            complete: ()=>{}
                        });
                }else{
                    console.log("登录失败"+ result.errMsg);
                }
            },
            fail: ()=>{},
            complete: ()=>{}
        });

    },
})